package org.dftproject.pgv.ui;

import org.dftproject.genesis.ui.figures.FigureCanvasEx;
import org.dftproject.genesis.ui.figures.PageContainer;
import org.dftproject.genesis.ui.pages.AbstractPagePart;
import org.dftproject.genesis.ui.pages.IPageInput;
import org.dftproject.genesis.ui.pages.IPageSite;
import org.dftproject.genesis.ui.pages.PageInitException;
import org.dftproject.genesis.ui.pages.PageUtils;
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.FigureCanvas;
import org.eclipse.swt.widgets.Composite;

public class PGVPage extends AbstractPagePart {

	public static final String ID = PGVPage.class.getName();
	
	private FigureCanvas canvas;

	public void init(IPageSite site, IPageInput input) throws PageInitException {
		if (!(input instanceof PGVPageInput))
			throw new PageInitException("input must be a " + PGVPageInput.class.getName());
		setInput(input);
		setSite(site);
	}

	@Override
	public void createPartControl(Composite parent) {		
		createContents(parent);
	}
	
	protected void createContents(Composite parent) {
		// Create the main Draw2D canvas

		canvas = new FigureCanvasEx(parent);

		// Create the root figure

		Figure topContainer = new PageContainer();
		canvas.getViewport().setContentsTracksWidth(true);
		canvas.setContents(topContainer);
		
		topContainer.add(PageUtils.createH1Label("PhpGedView Web site"));
		
		topContainer.add(PageUtils.createFlowedText("Coming soon!"));
	}

	@Override
	public void dispose() {
	}

	@Override
	public void setFocus() {
		canvas.setFocus();
	}

}
